﻿using Unity.Collections;
using Unity.Jobs;

namespace Other
{
    public class SumJob : IJobFor
    {
        [ReadOnly]
        [NativeDisableParallelForRestriction]
        public NativeArray<int> srcArray;
        [WriteOnly]
        public NativeReference<int> naiveSum; // 可以作为引用传递， 类似ref, 告知外面结果

        public void Execute(int index)
        {
            int val = srcArray[index];
            naiveSum.Value += val;
        }
    }
}